<?php
namespace app\serverfund\validate;
use \app\manage\validate\BaseValidate;
/**
 * 资金帐户的验证类
 * @author adv30 <adv30@126.com> 2017年6月19日10:44:56
 */
class FundAccount extends BaseValidate
{

    protected $rule = [
        'user_id' => ['integer', 'gt' => '0'],
        'obj_id' => ['integer', 'gt' => '0'],
        'order_id' => ['integer', 'gt' => '0'],
        'certi_transfer_fee' => ['number', 'egt' => '0'],
        'earnings' => ['number', 'egt' => '0'],
        'integral_deduction' => ['integer', 'egt' => '0'],
        'integral_deduction_money' => ['integer', 'egt' => '0'],
        'integral_deduction_currency' => ['number', 'egt' => '0'],
        'total_price' => ['number', 'egt' => '0'],
        'pay_method' => ['in'=>'cash,currency,alipay,wechat,unionpay'],
        'create_ip' => ['ip'],
        'update_ip' => ['ip'],
        'app_id' => ['integer', 'gt' => '0'],
        'opposite_id' => ['integer', 'gt' => '0', 'different' => 'user_id'],
        'borrow_log_id' => ['integer', 'gt' => '0'],
        'freeze_log_id' => ['integer', 'gt' => '0'],
        'user_ids' => ['length'=>'1,256'],
        'exchange' => ['in'=>'Currency,Integral'],
        'money' => ['integer', 'egt' => '0'],
        'integral' => ['integer', 'egt' => '0'],
        'currency_scale' => ['float','gt'=>'0','requireIf'=>'exchange,Currency'],
        'user_info' => ['regex'=>'^{.*}$'],
        'opposite_info' => ['regex'=>'^{.*}$'],
        'type' => ['in'=>'goods,certificate,order'],
        'obj_id' => ['integer', 'gt'=>'0'],
        'freeze_counts' => ['integer', 'gt'=>'0'],
        'reason' => ['min'=>5],
        'certificate_price' => ['number', 'gt'=>0],
        'certificate_id' => ['integer', 'gt'=>'0'],
        'certi_price' => ['integer', 'gt'=>'0'],
        'procedure_cost' => ['integer', 'gt'=>'0'],
    ];
    protected $message = [];
    protected $scene = [
        'init' => ['user_id', 'create_ip', 'app_id'],
        'prepaid' => ['user_id', 'money', 'update_ip', 'app_id'],
        'transfer' => ['user_id', 'opposite_id', 'money', 'update_ip', 'app_id', 'user_info', 'opposite_info'],
        'payment' => ['user_id', 'opposite_id', 'money', 'update_ip', 'app_id', 'user_info', 'opposite_info'],
        'borrow' => ['user_id', 'opposite_id', 'money', 'update_ip', 'app_id', 'user_info', 'opposite_info'],
        'refund' => ['user_id', 'opposite_id', 'money', 'update_ip', 'app_id', 'borrow_log_id', 'user_info', 'opposite_info'],
        'freeze' => ['user_id', 'opposite_id', 'money', 'update_ip', 'app_id', 'borrow_log_id', 'freeze_log_id', 'user_info', 'opposite_info','type','obj_id'],
        'unfreeze' => ['user_id', 'opposite_id', 'money', 'update_ip', 'app_id', 'borrow_log_id', 'freeze_log_id', 'user_info', 'opposite_info'],
        'list' => ['page', 'list_rows'],
        'listByUserIds' => ['user_ids'],
        'exchange' => ['exchange', 'money','app_id','currency_scale'],
        'userFund' => ['user_id'],
        'buyCertificate' => [
            'certificate_id', 'user_id', 'opposite_id', 'certi_price', 'procedure_cost', 
            'type' => ['in'=>'directional_sell,sell'], 
            'update_ip', 'app_id', 'user_info','opposite_info'
        ]
    ];
}
